package com.norman.sorry.core.tiles;

import java.awt.Color;
import java.util.List;

/**
 * A helper class for creating a concrete version of a linked slide.
 * 
 * @author Brian Norman
 * @version 0.0.1 beta
 * @since 0.0.1 beta
 */
public abstract class AbstractLinkedSlide extends AbstractSlide implements ILinkedSlide {

   /**
    * The tile that comes before this slide.
    */
   protected ILinkedTile previous;

   /**
    * The tile that comes after this tile. As the slide is a tile, the next tile
    * is the second tile in the slide or the tile that comes after the slide
    * depending on how long the slide is.
    */
   protected ILinkedTile next;

   /**
    * Creates a new linked slide with the given color.
    * 
    * @param color
    *           the color of the slide.
    */
   public AbstractLinkedSlide(Color color) {
      super(color);

      previous = null;
      next = null;
   }

   /**
    * Sets the tile that comes before this slide.
    * 
    * @param previous
    *           the tile that comes before this slide.
    */
   public void setPrevious(ILinkedTile previous) {
      this.previous = previous;
   }

   /**
    * {@inheritDoc}
    * 
    * @see com.norman.sorry.core.tiles.ILinkedTile#getPrevious()
    */
   @Override
   public ILinkedTile getPrevious() {
      return previous;
   }

   /**
    * Sets the tile that comes after this tile. As the slide is a tile, the next
    * tile is the second tile in the slide or the tile that comes after the
    * slide depending on how long the slide is.
    * 
    * @param next
    *           the tile that comes after this tile.
    */
   public void setNext(ILinkedTile next) {
      this.next = next;
   }

   /**
    * {@inheritDoc}
    * 
    * @see com.norman.sorry.core.tiles.ILinkedTile#getNext(Color)
    */
   @Override
   public ILinkedTile getNext(Color color) {
      return next;
   }

   public void add(ILinkedTile location) {
      super.add(location);
   }

   @SuppressWarnings("unchecked")
   @Override
   public List<ILinkedTile> getSlide() {
      return (List<ILinkedTile>) super.getSlide();
   }

   @Override
   public ILinkedTile getStart() {
      return (ILinkedTile) super.getStart();
   }

   @Override
   public ILinkedTile getEnd() {
      return (ILinkedTile) super.getEnd();
   }

}
